package kz.simplex.photobox.model;
// Generated Jul 19, 2009 4:45:38 PM by Hibernate Tools 3.2.2.GA

import static javax.persistence.GenerationType.IDENTITY;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.validator.Length;
import org.hibernate.validator.NotNull;

/**
 * Categories generated by hbm2java
 */
@Entity
@Table(name = "categories", catalog = "photobox")
public class Category implements java.io.Serializable {
	private Integer id;
	private Category parent;
	private String label;
	private List<Category> subcategories;
	private List<Album> albums;

	public Category() {
	}

	public Category(String label) {
		this.label = label;
	}
	public Category(Category parent, String label, List<Category> subcategories, List<Album> albums) {
		this.parent = parent;
		this.label = label;
		this.subcategories = subcategories;
		this.albums = albums;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name="parent", referencedColumnName="id")
	public Category getParent() {
		return this.parent;
	}
	public void setParent(Category parent) {
		this.parent = parent;
	}

	@Column(name = "label", nullable = false, length = 32)
	@NotNull
	@Length(max = 32)
	public String getLabel() {
		return this.label;
	}
	public void setLabel(String label) {
		this.label = label;
	}

	@OneToMany(mappedBy="parent")
	public List<Category> getSubcategories() {
		return subcategories;
	}
	public void setSubcategories(List<Category> subcategories) {
		this.subcategories = subcategories;
	}

	@OneToMany(mappedBy="category")
	public List<Album> getAlbums() {
		return albums;
	}
	public void setAlbums(List<Album> albums) {
		this.albums = albums;
	}
	
}
